<?php include incTemplate('header');?>
<script type="text/javascript">
$(function(){
	$('#news').datagrid({
		title:'新闻列表',
		nowrap: false,
		url:'/admin.php/news/newslist',
		remoteSort: true,
		rownumbers:true,
		pagination:true,
		singleSelect:true,
		idField:"id",
	    columns:[[  
	              {field:'title',title:'产品名称',width:350},  
	              {field:'createtime',title:'发布时间',width:180}
	    ]],
	    toolbar:[{
			id:'btnadd',
			text:'添加',
			iconCls:'icon-add',
			handler:function(){
				window.location.href="/admin.php/news/newsadd";
			}
		},{
			id:'btnedit',
			text:'修改',
			iconCls:'icon-edit',
			handler:function(){
				var sr = $('#news').datagrid("getSelected");
				if(sr){
					$("#id").val(sr.id);
					document.form1.submit();
				}else{
					$.messager.alert('提示','请选择新闻！');
				}
			}
		},'-',{
			id:'btndelete',
			text:'删除',
			iconCls:'icon-cut',
			handler:function(){
				var sr = $('#news').datagrid("getSelected");
				if(sr){
					$.post('/admin.php/news/newsdelete',{id:sr.id},function(data){
						if(data.success){
							$.messager.alert('提示','删除成功！');
							$('#product').datagrid("reload");
						}else{
							$.messager.alert('提示','删除操作没有成功！'); 
						}
					},'json');
				}else{
					$.messager.alert('提示','请选择新闻！'); 
				}
			}
		}]
	});
});
</script>
</head>
<body class="body" >
<form action="/admin.php/news/newsupdate" method="post" name="form1">
<input type="hidden" value="" name="id" id="id" />
	<table id="news"></table>
</form>
</body>
</html>